<template>
    <view class="myConsultation">
        <Navigation title="我的问诊" backType="back" background="#fff" />
        <view class="bg mt-20 ph-32 pt-32" v-for="(item,index) in list" @click="toDetail(item)">
            <view class="fs-24 text-color3"> 订单编号：{{item.no}}</view>
            <view class="f ai-c pv-32">
                <image :src="item.petsDO.avatar" class="w-130 h-130 b-12 mr-20" v-if="item.petsDO"></image>
                <view>
                    <view class="fs-28 fw-600 text-color4" v-if="item.petsDO">{{item.petsDO.name}}</view>
                    <view class="fs-24 mt-8 text-color3">
                        问诊方式：
						<text class="text-color4" v-if="item.type==1">图文</text>
						<text class="text-color4" v-if="item.type==2">语音</text>
						<text class="text-color4" v-if="item.type==3">电话</text>
                    </view>
					
                    <view class="fs-26 fw-600 text-color7 mt-12">¥{{item.totalPrice}}</view>
                </view>
              
            </view>
            <view class="fs-24 text-color3 pv-24 time">时间：{{item.createTime}}</view>
        </view>
    </view>
</template>
<script setup lang="ts">
	import { ref,getCurrentInstance } from 'vue';
	import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
	import { orderPage,formatTimestamp } from '@/services/api/index';
	import { useAuthStore } from '@/store/modules/auth';
	// const { proxy } = getCurrentInstance();
	const list = ref<any[]>([]);
	const keyword = ref('');
const authStore = useAuthStore();
	const listParams = ref<any>({
		// doctorId:1,
		doctorId:authStore.getUserId,
	    pageNo: 1,
	    pageSize: 10,
		keyword:''
	});
onLoad(() => {
		
	    getList();
	});
	
	async function getList() {
	    const { data } = await orderPage(listParams.value);
		data.list.forEach((item: any) => {

			if(item.createTime){
				
				item.createTime = formatTimestamp(item.createTime);
			}
			
		});
	    list.value = list.value.concat(data.list);
	}	

function toSearch() {
   list.value = [];
   listParams.value.pageNo = 1;
   getList();
}

function toDetail(item: any) {
    uni.navigateTo({
        url: `/pages_index/orderdetail?id=${item.id}`,
    });
}

//下拉刷新
	onPullDownRefresh(() => {
	    list.value = [];
	    listParams.value.pageNo = 1;
	    getList();
	});
	//上拉加载
	onReachBottom(() => {
	    listParams.value.pageNo++;
	    getList();
	});

</script>
<style lang="scss" scoped>
.myConsultation {
    background: #f5f5f5;
    min-height: 100vh;
    .time{
        border-top: 1px solid #f5f5f5;
    }
   
    .bg{
        background: #fff;
    }
}
</style>